﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EONFULLSIN2.Core.Helpers
{
    public class ParseHelper
    {
        //i：输入电流 Smin~Smax测量范围
        /// <summary>
        /// 数值范围转化映射
        /// </summary>
        /// <param name="I">需要映射的输入值</param>
        /// <param name="Smin">目标范围最小值</param>
        /// <param name="Smax">目标范围最大值</param>
        /// <param name="Imin">输入范围最小值，默认：4</param>
        /// <param name="Imax">输入范围最大值，默认：20</param>
        /// <returns></returns>
        public static double MapValue(double I, double Smin, double Smax, double Imin = 4, double Imax = 20)
        {
            // 线性映射公式
            double S = ((I - Imin) * (Smax - Smin)) / (Imax - Imin) + Smin;
            var result = Math.Round(S, 2);
            return result;
        }
    }
}
